home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performTextureViewImageRange < prev    next >
Encoding:
Text File  |  2003-07-17  |  12.1 KB  |  467 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Nov 24, 19987
  22. //
  23. //  Description:
  24. //      This script is use to display and update the image range options.
  25. //
  26. //  Input Arguments:
  27. //        None.
  28. //
  29. //  Return Value:
  30. //      None.
  31. //
  32.  
  33. proc string tvImageRangePanelName()
  34. //
  35. //  Procedure Name:
  36. //      textureWindowPanelName
  37. //
  38. //  Description:
  39. //        return the texture window panel name.
  40. //
  41. //  Input Arguments:
  42. //        
  43. //
  44. //  Return Value:
  45. //      texture window panel name
  46. //
  47. {
  48.     string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`;
  49.     return $texWinName[0];
  50. }
  51.  
  52. proc setOptionVars(int $forceFactorySettings)
  53. //
  54. //  Procedure Name:
  55. //      setOptionVars
  56. //
  57. //  Description:
  58. //        Initialize the option values.
  59. //
  60. //  Input Arguments:
  61. //        Whether to set the options to default values.
  62. //
  63. //  Return Value:
  64. //      None.
  65. //
  66. {
  67.     if ($forceFactorySettings || !`optionVar -exists tvImageRangeMinU`) {
  68.         optionVar -fv tvImageRangeMinU 0.0;
  69.     }
  70.     if ($forceFactorySettings || !`optionVar -exists tvImageRangeMinV`) {
  71.         optionVar -fv tvImageRangeMinV 0.0;
  72.     }
  73.     if ($forceFactorySettings || !`optionVar -exists tvImageRangeMaxU`) {
  74.         optionVar -fv tvImageRangeMaxU 1.0;
  75.     }
  76.     if ($forceFactorySettings || !`optionVar -exists tvImageRangeMaxV`) {
  77.         optionVar -fv tvImageRangeMaxV 1.0;
  78.     }
  79.     if ($forceFactorySettings || !`optionVar -exists tvImageRangePresets`) {
  80.         optionVar -iv tvImageRangePresets 1;
  81.     }
  82. }
  83.  
  84. global proc tvImageRangeSetup(string $parent, int $forceFactorySettings)
  85. //
  86. //  Procedure Name:
  87. //      tvImageRangeSetup
  88. //
  89. //  Description:
  90. //        Update the state of the option box UI to reflect the option values.
  91. //
  92. //  Input Arguments:
  93. //      parent               - Top level parent layout of the option box UI.
  94. //                             Required so that UI object names can be 
  95. //                             successfully resolved.
  96. //
  97. //    forceFactorySettings - Whether the option values should be set to
  98. //                             default values.
  99. //
  100. //  Return Value:
  101. //      None.
  102. //
  103. {
  104.     setParent $parent;
  105.  
  106.     setOptionVars($forceFactorySettings);
  107.  
  108.     string $winName = tvImageRangePanelName();
  109.  
  110.     float $rangeMinU = `optionVar -query tvImageRangeMinU`;
  111.     float $rangeMinV = `optionVar -query tvImageRangeMinV`;
  112.     float $rangeMaxU = `optionVar -query tvImageRangeMaxU`;
  113.     float $rangeMaxV = `optionVar -query tvImageRangeMaxV`;
  114.  
  115.     floatSliderGrp -edit -value $rangeMinU tvImageRangeMinU;
  116.     floatSliderGrp -edit -value $rangeMinV tvImageRangeMinV;
  117.     floatSliderGrp -edit -value $rangeMaxU tvImageRangeMaxU;
  118.     floatSliderGrp -edit -value $rangeMaxV tvImageRangeMaxV;   
  119.  
  120.     int $preset = `optionVar -query tvImageRangePresets`;
  121.     radioButtonGrp -edit -select $preset tvImageRangePresets;
  122. }
  123.  
  124. global proc tvImageRangeCallback(string $parent, int $doIt)
  125. //
  126. //  Procedure Name:
  127. //      tvImageRangeCallback
  128. //
  129. //  Description:
  130. //        Update the option values with the current state of the option box UI.
  131. //
  132. //  Input Arguments:
  133. //      parent - Top level parent layout of the option box UI.  Required so
  134. //               that UI object names can be successfully resolved.
  135. //
  136. //    doIt   - Whether the command should execute.
  137. //
  138. //  Return Value:
  139. //      None.
  140. //
  141. {
  142.     optionVar -fv tvImageRangeMinU
  143.         `floatSliderGrp -q -value tvImageRangeMinU`;
  144.     optionVar -fv tvImageRangeMinV
  145.         `floatSliderGrp -q -value tvImageRangeMinV`;
  146.     optionVar -fv tvImageRangeMaxU
  147.         `floatSliderGrp -q -value tvImageRangeMaxU`;
  148.     optionVar -fv tvImageRangeMaxV
  149.         `floatSliderGrp -q -value tvImageRangeMaxV`;
  150.     optionVar -iv tvImageRangePresets
  151.         `radioButtonGrp -query -select tvImageRangePresets`;
  152.  
  153.     if ($doIt) {
  154.         performTextureViewImageRangeOptions 0; 
  155.         addToRecentCommandQueue "performTextureViewImageRangeOptions 0" "TextureViewImageRange";
  156.     }
  157. }
  158.  
  159. global proc tvImageRangeCheckRange()
  160. //
  161. // Description:
  162. //        Check if image ranges are valid.
  163. // Arguments:
  164. //
  165. // Returns:
  166. //
  167. //
  168. {
  169.     float $minU, $minV, $maxU, $maxV;
  170.  
  171.     $minU = `floatSliderGrp -query -value tvImageRangeMinU`;
  172.     $minV = `floatSliderGrp -query -value tvImageRangeMinV`;
  173.     $maxU = `floatSliderGrp -query -value tvImageRangeMaxU`;
  174.     $maxV = `floatSliderGrp -query -value tvImageRangeMaxV`;
  175.  
  176.     if ($minU > $maxU)
  177.     {
  178.         $maxU = $minU;
  179.         floatSliderGrp -edit -value $maxU tvImageRangeMaxU;
  180.     }
  181.  
  182.     if ($minV > $maxV)
  183.     {
  184.         $maxV = $minV;
  185.         floatSliderGrp -edit -value $maxV tvImageRangeMaxV;
  186.     }
  187. }
  188.  
  189. global proc tvImageRangeCheckPresets()
  190. //
  191. // Description:
  192. //        Update UI to presets
  193. // Arguments:
  194. //
  195. // Returns:
  196. //
  197. //
  198. {
  199.     int $preset = `radioButtonGrp -query -select tvImageRangePresets`;
  200.     if ($preset == 2)
  201.     {
  202.         if (`optionVar -exists textureWindowGridSize`)
  203.         {
  204.             float $gridSize = `optionVar -q textureWindowGridSize`;
  205.             float $negGridSize = 0.0 - $gridSize;
  206.             
  207.             floatSliderGrp -edit -value $negGridSize tvImageRangeMinU;
  208.             floatSliderGrp -edit -value $negGridSize tvImageRangeMinV;
  209.             floatSliderGrp -edit -value $gridSize tvImageRangeMaxU;
  210.             floatSliderGrp -edit -value $gridSize tvImageRangeMaxV;
  211.         }
  212.     }
  213.     else if ($preset == 3)
  214.     {
  215.         floatSliderGrp -edit -value 0.0 tvImageRangeMinU;
  216.         floatSliderGrp -edit -value 0.0 tvImageRangeMinV;
  217.         floatSliderGrp -edit -value 1.0 tvImageRangeMaxU;
  218.         floatSliderGrp -edit -value 1.0 tvImageRangeMaxV;
  219.     }
  220. }
  221.  
  222. //
  223. //  Procedure Name:
  224. //      tvImageRangeOptions
  225. //
  226. //  Description:
  227. //        Construct the option box UI.  Involves accessing the standard option
  228. //        box and customizing the UI accordingly.
  229. //
  230. //  Input Arguments:
  231. //      None.
  232. //
  233. //  Return Value:
  234. //      None.
  235. //
  236. proc tvImageRangeOptions()
  237. {
  238.     //    Name of the command for this option box.
  239.     //
  240.     string $commandName = "tvImageRange";
  241.  
  242.     //    Build the option box actions.
  243.     //
  244.     string $callback = ($commandName + "Callback");
  245.     string $setup = ($commandName + "Setup");
  246.  
  247.      //    STEP 1:  Get the option box.
  248.     //    ============================
  249.     //
  250.     //    The value returned is the name of the layout to be used as
  251.     //    the parent for the option box UI.
  252.     //
  253.     string $layout = getOptionBox();
  254.     setParent $layout;
  255.     
  256.     //    STEP 2:  Pass the command name to the option box.
  257.     //    =================================================
  258.     //
  259.     //    Any default option box behaviour based on the command name is set 
  260.     //    up with this call.  For example, updating the 'Help' menu item with
  261.     //    the name of the command.
  262.     //
  263.     setOptionBoxCommandName($commandName);
  264.     
  265.     //    STEP 3:  Activate the default UI template.
  266.     //    ==========================================
  267.     //
  268.     //    Activate the default UI template so that the layout of this 
  269.     //    option box is consistent with the layout of the rest of the 
  270.     //    application.
  271.     //
  272.     setUITemplate -pushTemplate DefaultTemplate;
  273.  
  274.     //    STEP 4: Create option box contents.
  275.     //    ===================================
  276.     //    
  277.     //    This, of course, will vary from option box to option box.    
  278.     //    Turn on the wait cursor.
  279.     //
  280.     waitCursor -state 1;
  281.  
  282.     tabLayout -tabsVisible 0 -scrollable 1;
  283.     
  284.     string $parent = `columnLayout -adjustableColumn 1`;
  285.  
  286.     floatSliderGrp -l "Minimum U" 
  287.         -minValue -50.0 -maxValue 50.0
  288.         -fieldMinValue -50.0 -fieldMaxValue 50.0
  289.         -cc ("tvImageRangeCheckRange")
  290.         tvImageRangeMinU;
  291.  
  292.     floatSliderGrp -l "Minimum V" 
  293.         -minValue -50.0 -maxValue 50.0
  294.         -fieldMinValue -50.0 -fieldMaxValue 50.0
  295.         -cc ("tvImageRangeCheckRange")
  296.         tvImageRangeMinV;
  297.  
  298.     floatSliderGrp -l "Maximum U" 
  299.         -minValue -50.0 -maxValue 50.0
  300.         -fieldMinValue -50.0 -fieldMaxValue 50.0
  301.         -cc ("tvImageRangeCheckRange")
  302.         tvImageRangeMaxU;
  303.  
  304.     floatSliderGrp -l "Maximum V" 
  305.         -minValue -50.0 -maxValue 50.0
  306.         -fieldMinValue -50.0 -fieldMaxValue 50.0
  307.         -cc ("tvImageRangeCheckRange")
  308.         tvImageRangeMaxV;
  309.  
  310.     radioButtonGrp -numberOfRadioButtons 3
  311.         -select 1
  312.         -label "Presets"
  313.         -label1 "None"
  314.         -label2 "Grid Size"
  315.         -label3 "Unit Size"
  316.         -cc ("tvImageRangeCheckPresets")
  317.         tvImageRangePresets;
  318.  
  319.     //    Turn off the wait cursor.
  320.     //
  321.     waitCursor -state 0;
  322.     
  323.     //    Step 5: Deactivate the default UI template.
  324.     //    ===========================================
  325.     //
  326.     setUITemplate -popTemplate;
  327.  
  328.     //    Step 6: Customize the buttons.  
  329.     //    ==============================
  330.     //
  331.     //    Provide more descriptive labels for the buttons.  This is not 
  332.     //    necessary, but in some cases, for example, a button labelled 
  333.     //    'Create' may be more meaningful to the user than one labelled
  334.     //    'Apply'.
  335.     //
  336.     //    Disable those buttons that are not applicable to the option box.
  337.     //
  338.     //    Attach actions to those buttons that are applicable to the option
  339.     //    box.  Note that the 'Close' button has a default action attached 
  340.     //    to it that will hide the window.  If a a custom action is
  341.     //    attached to the 'Close' button then be sure to call the 'hide the
  342.     //    option box' procedure within the custom action so that the option
  343.     //    box is hidden properly.
  344.  
  345.     //    'Apply' button.
  346.     //
  347.     string $applyBtn = getOptionBoxApplyBtn();
  348.     button -edit
  349.         -command ($callback + " " + $parent + " " + 1)
  350.         $applyBtn;
  351.  
  352.     //    'Save' button.
  353.     //
  354.     string $saveBtn = getOptionBoxSaveBtn();
  355.     button -edit 
  356.         -command ($callback + " " + $parent + " " + 1 + "; hideOptionBox")
  357.         $saveBtn;
  358.  
  359.     //    'Reset' button.
  360.     //
  361.     string $resetBtn = getOptionBoxResetBtn();
  362.     button -edit 
  363.         -command ($setup + " " + $parent + " " + 1)
  364.         $resetBtn;
  365.  
  366.     //    Step 7: Set the option box title.
  367.     //    =================================
  368.     //
  369.     setOptionBoxTitle("Image Range Options");
  370.  
  371.     //    Step 8: Customize the 'Help' menu item text.
  372.     //    ============================================
  373.     //
  374.     setOptionBoxHelpTag( "UVTextureEditorImageRange" );
  375.  
  376.     //    Step 9: Set the current values of the option box.
  377.     //    =================================================
  378.     //
  379.     eval (($setup + " " + $parent + " " + 0));    
  380.     
  381.     //    Step 10: Show the option box.
  382.     //    =============================
  383.     //
  384.     showOptionBox();
  385. }
  386.  
  387.  
  388. //
  389. //  Procedure Name:
  390. //      assembleCmd
  391. //
  392. //  Description:
  393. //        Construct the command that will apply the option box values.
  394. //
  395. //  Input Arguments:
  396. //      None.
  397. //
  398. proc string assembleCmd()
  399. {
  400.     string $cmd;
  401.  
  402.     setOptionVars(false);
  403.  
  404.     float $rangeMinU = `optionVar -query tvImageRangeMinU`;
  405.     float $rangeMinV = `optionVar -query tvImageRangeMinV`;
  406.     float $rangeMaxU = `optionVar -query tvImageRangeMaxU`;
  407.     float $rangeMaxV = `optionVar -query tvImageRangeMaxV`;
  408.  
  409.     string $winName = tvImageRangePanelName();
  410.  
  411.     $cmd = "textureWindow -edit -imageTileRange " +
  412.         $rangeMinU + " " + 
  413.         $rangeMinV + " " + 
  414.         $rangeMaxU + " " + 
  415.         $rangeMaxV + " " + 
  416.         $winName;
  417.  
  418.     return $cmd;
  419. }
  420.  
  421. //
  422. //  Procedure Name:
  423. //      performTextureViewImageRangeOptions
  424. //
  425. //  Description:
  426. //
  427. //  Input Arguments:
  428. //      0 - Execute the command.
  429. //      1 - Show the option box dialog.
  430. //      2 - Return the command.
  431. //
  432. global proc string performTextureViewImageRangeOptions(int $action)
  433. {
  434.     string $cmd = "";
  435.  
  436.     switch ($action) {
  437.  
  438.         //    Execute the command.
  439.         //
  440.         case 0:
  441.             //    Get the command.
  442.             //
  443.             $cmd = `assembleCmd`;
  444.  
  445.             //    Execute the command with the option settings.
  446.             //
  447.             eval($cmd);
  448.             break;
  449.  
  450.         //    Show the option box.
  451.         //
  452.         case 1:
  453.             tvImageRangeOptions;
  454.             break;
  455.  
  456.         //    Return the command string.
  457.         //
  458.         case 2:
  459.             //    Get the command.
  460.             //
  461.             $cmd = `assembleCmd`;
  462.             break;
  463.     }
  464.     return $cmd;
  465. }
  466.  
  467.